/**
 * Bestpay.com.cn Inc.
 * Copyright (c) 2011-2019 All Rights Reserved.
 */
package javabasics.lambda.stream;

import javabasics.lambda.entity.Artist;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author zhaorongzhang
 * @version Id: StreamTest.java, v 0.1 2019/6/9 23:28 zhaorongzhang Exp $$
 */
public class StreamTest {

    public static void main(String[] args) {
        List<Artist> artistList = new ArrayList<>();

        Artist artist = new Artist();
        artist.setName("lili");
        artist.setOrigin("london");

        Artist artist1 = new Artist();
        artist1.setName("zrz");
        artist1.setOrigin("london");

        Artist artist2 = new Artist();
        artist2.setName("gg");
        artist2.setOrigin("london");

        Artist artist3 = new Artist();
        artist3.setName("mm");
        artist3.setOrigin("huaxian");

        artistList.add(artist);
        artistList.add(artist1);
        artistList.add(artist2);
        artistList.add(artist3);

        long count = artistList.stream()
                .filter(artistItem -> artistItem.isFrom("london"))
                .count();

        System.out.println(count);

        artistList.stream().filter(artistItem -> {
            System.out.println(artistItem.getName());
            return artistItem.isFrom("london");
        }).count();

        List<String> collected = Stream.of("a", "b", "c").collect(Collectors.toList());

        assert Arrays.asList("a", "b", "c").equals(collected);

    }

}